package cc.uncarbon.module.appapi.service;


import cc.uncarbon.module.appapi.mapper.BlinkMapper;
import cc.uncarbon.module.appapi.model.response.BlinkBO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yanrumiao.entity.BlinkEntity;
import com.yanrumiao.util.ConvertUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@Service
@Slf4j
public class BlinkService {


    private final BlinkMapper blinkMapper;

    public List<BlinkBO> getList(Long storeId) {
        List<BlinkEntity> blinkList= blinkMapper.selectList(new QueryWrapper<BlinkEntity>().lambda()
                .orderByAsc(BlinkEntity::getSort));

        List<BlinkBO> bo=new ArrayList<>(blinkList.size());
        if(blinkList.isEmpty()){
            return bo;
        }
        blinkList.forEach(item->bo.add(ConvertUtil.boToVo(item, BlinkBO.class)));
        return bo;
    }
}
